package cn.haiway.drools.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @author Haiway  on 2019/4/25
 */
@Component
@Data
@ConfigurationProperties(prefix = "spring.redis.jedis.pool")
public class RedisProperties {
    private Integer maxIdle;
    private Integer minIdle;
    private Integer maxActive;
    private Long maxWait;

    @Bean
    public JedisPoolConfig JedisPoolConfig(){
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxIdle(maxIdle);
        jedisPoolConfig.setMinIdle(minIdle);
        jedisPoolConfig.setMaxTotal(maxActive);
        jedisPoolConfig.setMaxWaitMillis(maxWait);

        return jedisPoolConfig;
    }
}
